package com.zlzxm.studentscreen.net.http.repository;


import com.zlzxm.studentscreen.net.http.RetrofitClient;
import com.zlzxm.studentscreen.net.http.api.MyApi;
import com.zlzxm.studentscreen.net.http.request.RqBindDevice;
import com.zlzxm.studentscreen.net.http.request.RqDeviceStatus;
import com.zlzxm.studentscreen.net.http.request.RqDevice;
import com.zlzxm.studentscreen.net.http.response.BaseResponse;
import com.zlzxm.studentscreen.net.http.response.RpBindDevice;
import com.zlzxm.studentscreen.net.http.response.RpDeviceStatus;
import com.zlzxm.studentscreen.net.http.response.RpInfo;
import com.zlzxm.studentscreen.net.http.response.RpUnBindDevice;

import java.util.List;

import io.reactivex.Observable;

/**
 * Created by zlz
 * on  2020/11/12
 */
public class MyRepository {


    MyApi myApi = RetrofitClient.get().create(MyApi.class);


    public Observable<BaseResponse<RpInfo>> info(String deviceId){

        RqDevice rqDevice = new RqDevice();
        rqDevice.setDeviceId(deviceId);
        return myApi.info(rqDevice);
    }


    public Observable<BaseResponse<RpDeviceStatus>> status(String deviceId){
        RqDeviceStatus rqDeviceStatus= new RqDeviceStatus();
        rqDeviceStatus.setDeviceNo(deviceId);
        return  myApi.status(rqDeviceStatus);
    }

    public Observable<BaseResponse<List<RpUnBindDevice>>> list(){

        return  myApi.unBindList();
    }

    public   Observable<BaseResponse<RpBindDevice>> bindDevice(String groupId, String deviceNo,
                                                               String deviceName){

        RqBindDevice rqBindDevice = new  RqBindDevice();
        rqBindDevice.setDeviceNo(deviceNo);
        rqBindDevice.setGroupId(groupId);
        rqBindDevice.setDeviceName(deviceName);

        return  myApi.bindDevice(rqBindDevice);
    }


}
